package com.xhs.service.impl;

import com.xhs.service.DecorateService;
import com.xhs.utils.JvmMapCacheUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * @desc: 一级缓存JVM
 * @projectName: tools-parent
 * @author: xhs
 * @date: 2022/12/4 23:31
 * @version: JDK 1.8
 */
@Slf4j
@Service
public class CacheJvmServiceImpl implements DecorateService {

    /**
     * 查询缓存中的数据
     *
     * @param key
     * @param <T>
     * @return
     */
    @Override
    public <T> T getCache(String key) {
        // 查询一级缓存 jvm缓存
        String entity = JvmMapCacheUtils.getEntity(key, String.class);
        log.info("---------------查询一级缓存---------------");
        if (entity == null) {
            return null;
        }
        return (T) entity;
    }
}
